﻿/* Write a program to convert hexadecimal numbers to their decimal representation. */

using System;

class DecimalToHex
{
    static void Main()
    {
        string num = Console.ReadLine();
        Int32 power = num.Length - 1;
        Int32? result = 0, nl_rep = 0; //numeric representation of a letter
        for (int i = 0; i < num.Length; i++)
        {
            switch (char.ToUpper(num[i]))
            {
                case 'A': 
                    nl_rep = 10;
                    break;
                case 'B': 
                    nl_rep = 11;
                    break;
                case 'C': 
                    nl_rep = 12;
                    break;
                case 'D': 
                    nl_rep = 13;
                    break;
                case 'E': 
                    nl_rep = 14;
                    break;
                case 'F': 
                    nl_rep = 15;
                    break;
                default: 
                    nl_rep = int.Parse(Convert.ToString(num[i]));
                    break;
            }
            result += nl_rep * (Int32)(Math.Pow(16, power));
            power--;
        }

        //output result
        Console.WriteLine(result);
    }
}
